package com.cpecc.quartz;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cpecc.dao.system.EmailDao;
import com.cpecc.dao.system.YouJianDao;
import com.cpecc.dao.wuzi.WuZiDao;
import com.cpecc.mail.SendMailThread1;
import com.cpecc.model.system.Email;
import com.cpecc.model.system.User;
import com.cpecc.model.system.YouJian;
import com.cpecc.model.wuzi.WuZi;

@Service
public class PreBaoFeiSchedule{
	
	@Autowired
	private WuZiDao wuZiDao;
	
	@Autowired
	private EmailDao emailDao;
	
	@Autowired
	private YouJianDao youJianDao;
	
	public void preBaoFei() {
		List<User> userList=wuZiDao.getYuBaoFeiUsers();
		Email email=emailDao.getEmail2();
		for(User user:userList){			
			if(user.getEmail()!=null && !user.getEmail().equals("")){
				List<WuZi> wuZiList=wuZiDao.getYuBaoFeiForUser(user);
				for(WuZi wuZi:wuZiList){
					YouJian youJian=youJianDao.get2(4);
					SendMailThread1 st=new SendMailThread1(email, user, youJian, wuZi);
					Thread t=new Thread(st);
					t.start();
				}
			}
		}
	}
}